<?php
namespace Org\Util;
class Token {
	/**
	 *生成token
	 */
	//加密
	protected $des;
	public function __construct(){
		$this->des=new \Think\Crypt\Driver\Crypt();
	}
	public function encryptToken($data, $key,$expire) {
		$code=$this->des->encrypt($data,$key,$expire);
		return base64_encode($code);
	}
	//解密
    public function decryptToken($data, $key){
		$data=base64_decode($data);
		$uid=$this->des->decrypt($data,$key);
		if($uid){
			return $uid;
		}
		else {
			return false;
		}
    }
}
